package golf.stockdata.framework.spring;

import java.util.Properties;

import golf.stockdata.framework.common.Ability;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class StockDataBeanPostProcessing implements BeanPostProcessor {

    private StockDataBeanFactoryPostProcessor beanFactoryPostProcessor;
    
	public Object postProcessAfterInitialization(Object bean, String str)
			throws BeansException {
		
		if(bean instanceof Ability){
			Ability ability = (Ability)bean;
			
			Properties props = beanFactoryPostProcessor.getAbilityInitProps(str);
			
            if (props == null) {
                props = new Properties();
            }
            
            ability.initializeAbility(props);

		}
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String str)
			throws BeansException {
		return bean;
	}

    public void setBeanFactoryPostProcessor(StockDataBeanFactoryPostProcessor value) {
        beanFactoryPostProcessor = value;
    }
}
